package tasks.OpportunitiesBaseData.MainView;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import tasks.Brand;

import com.ibm.jvm.dtfjview.commands.SetCommand;

import core.Functions;
import core.testcases.TestProjectSuperHelper;

public class STGLayout extends BrandLayout {
	
	//Attributes for STG
	private String insideSalesInv;
	private String fcstDate;
	private String subbrand;
	private String prismRev;
	private String ibssRev;
	
	
	public String getInsideSalesInv() {
		return insideSalesInv;
	}
	
	public void setInsideSalesInv(String insideSalesInv) {
		this.insideSalesInv = (insideSalesInv != null)?escapeSpecChars(insideSalesInv.trim()):"";
	}
	
	public String getFcstDate() {
		String retVal = "";
		
		String patternFE = "MMM dd yyyy";
		String patternDB = "yyyy-MM-dd";
		
	    SimpleDateFormat format = null;
	    
	    if(this.fcstDate.contains("-"))
	    {
	    	format = new SimpleDateFormat(patternDB);
	    }
	    else
	    {
	    	format = new SimpleDateFormat(patternFE);
	    }
	    
	    try {
	      Date date = format.parse(this.fcstDate);
	      retVal = date.toString();
	    } catch (ParseException e) {
	      e.printStackTrace();
	    }
		
		return retVal;
	}
	public void setFcstDate(String fcstDate) {
		this.fcstDate = (fcstDate != null)?escapeSpecChars(fcstDate.trim()):"";
	}
	public String getSubbrand() {
		return subbrand;
	}
	public void setSubbrand(String subbrand) {
		this.subbrand = (subbrand != null)?escapeSpecChars(subbrand.trim()):"";
	}
	
	public String getPrismRev() {
		String retVal = "";
		
		retVal = Functions.formatDoubleToString(Double.parseDouble(prismRev), 1);
		
		return retVal;
	}
	public void setPrismRev(String prismRev) {
		this.prismRev = (prismRev != null)?escapeSpecChars(prismRev.trim()):"";
	}
	public String getIbssRev() {
		String retVal = "";
		
		retVal = Functions.formatDoubleToString(Double.parseDouble(ibssRev), 1);
		
		return retVal;
	}
	public void setIbssRev(String ibssRev) {
		this.ibssRev = (ibssRev != null)?escapeSpecChars(ibssRev.trim()):"";
	}	
	
	public boolean isEqual(STGLayout layout)
	{
		boolean result = super.isEqual(layout);
		
		if(!this.getInsideSalesInv().equals(layout.getInsideSalesInv())) 
		{ 
			result = false;
			setComment("Difference in Inside Sales Inv  -   " + this.getInsideSalesInv() + " != " + layout.getInsideSalesInv()); 
		}
		
		if(!this.getFcstDate().equals(layout.getFcstDate())) 
		{ 
			result = false;
			setComment("Difference in Fcst Date   -   " + this.getFcstDate() + " != " + layout.getFcstDate()); 
		}
		
		if(!this.getSubbrand().equals(layout.getSubbrand())) 
		{ 
			result = false;
			setComment("Difference in Subbrand   -   " + this.getSubbrand() + " != " + layout.getSubbrand()); 
		}
		
		if(!this.getPrismRev().equals(layout.getPrismRev())) 
		{ 
			result = false;
			setComment("Difference in Prism Rev   -   " + this.getPrismRev() + " != " + layout.getPrismRev()); 
		}
		
		if(!this.getIbssRev().equals(layout.getIbssRev())) 
		{ 
			result = false;
			setComment("Difference in Ibss Rev   -   " + this.getIbssRev() + " != " + layout.getIbssRev()); 
		}
		
		return result;
		
	}
}
